<template>
	<h3>HOME</h3>
	<el-row>
		<el-button @click="click1" type="primary">直接用axios</el-button>
		<el-button @click="click2" type="primary">用封装的axios</el-button>
		<el-button @click="click3({ username: '', password: '' })" type="primary">测试登录请求</el-button>
	</el-row>
</template>
<script setup lang="ts" name="home">
import axios from "axios";
import http from "@/api";
import { Login } from "@/api/login/index";
// 测试发请求
// 直接用axios
const click1 = () => {
	axios.get("/api/test").then(result => {
		console.log(result);
	});
};
// 用封装的axios
const click2 = () => {
	http.get("/test").then(res => {
		console.log(res);
	});
	// 不要loading
	// http.get("/test", {}, { headers: { noLoading: true } }).then(res => {
	// 	console.log(res);
	// });
};
// 测试登录请求
const click3 = async (params: Login.ReqLoginForm) => {
	// Login.ResLogin触发不了ts类型验证,和方法定义那里不一致，因为promise这里没得那里写返回值类型
	const res = await http.get<Login.ResLogin>("/login", params);
	console.log(res);
};
</script>
<style lang="scss" scoped></style>
